package com.zretc.support.dao;

import com.zretc.support.entity.Message;
import com.zretc.support.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

public interface MessageDao extends JpaRepository<Message,Integer>, JpaSpecificationExecutor<Message>,
        CrudRepository<Message,Integer>, Serializable {

    //模糊查询
    @Query("select m from Message m where m.messageContent like %?1%")//对应第1个参数
    Page<Message> selectByPage(String keywords, Pageable pageable);

    //时间段查询
    @Query("select m from Message m where m.messageDate between ?1 and ?2")//对应第1个参数
    Page<Message> selectByDate(Date time1, Date time2, Pageable pageable);

    //根据课程编号查
    @Query("select m from Message m where m.course.courseId in (?1)")
    Page<Message> selectByCourseId(List<Long> couresId, Pageable pageable);


}
